package com.credithc.customers.manager.echarts;

import com.credithc.customers.base.po.CustomerStatsPo;
import com.github.abel533.echarts.code.Orient;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhukai
 */
public class CustomerCountStats extends EChartsCommon {

    private static List<String> rowList = new ArrayList<>();

    static {
        rowList.add("用户");
        rowList.add("个人客户");
        rowList.add("对公客户");
    }

    public CustomerCountStats(List<CustomerStatsPo> pos, List<String> colList) {
        super(rowList, colList);
        for (CustomerStatsPo po : pos) {
            setValue(getChineseType(po.getType()), po.getDate(), po.getCount());
        }
    }

    private String getChineseType(String type) {
        switch (type) {
            case "pre":
                return "用户";
            case "personal":
                return "个人客户";
            case "public":
                return "对公客户";
            default:
                return null;
        }
    }

    public String generateGraph() {
        return createGraph("客户统计", null).createGrid(50, 80, 50, 450).createCategoryXAxis(columnList, true, true).createValueYAxis("数量", null, null,true).createLine(false,true).createLeftLegend(rowList, 0, 0, Orient.horizontal).toJSONString();
    }
}